package stateAAs 
{
	import org.agony2d.Agony;
	import org.agony2d.gpu.ImageAA;
	import org.agony2d.gpu.StateAA;
	import org.agony2d.notify.AEvent;
	
public class Image_StateAA extends StateAA 
{
	
	/** overwritable... */
	override public function get smoothing() : Boolean {
		return true
	}
	
	/** overwritable... */
//	override public function get tinted() : Boolean {
//		return true
//	}
	
	/** overwrite... */
	override public function get fullTexture() : String {
		return "A_32"
	}
	
	/** overwrite... */
	override public function enter() : void {
		var image:ImageAA
		var i:int
		
		this.group.interactive = false
		
		mLength = this.stateArgs[0]
		while (i < mLength) {
			mImgList[i++] = this.createImg()
		}
		
		Agony.process.addEventListener(AEvent.ENTER_FRAME, update)
	}
	
	/** overwrite... */
	override public function exit() : void {
		
	}
	
	
	private var mImgList:Array = []
	private var mLength:int
	
	
	private function createImg(): ImageAA{
		var image:ImageAA
		
		image = new ImageAA
		
		image.x = 60 + Math.random() * 540
		image.y = 70 + Math.random() * 330
		image.pivotX = 16
		image.pivotY = 16
		image.rotation = Math.random()*180
		this.group.addNode(image)
		image.textureData = FULL_TEX
//		image.alpha = 0.8
//		image.scaleX = image.scaleY = 0.75
//		image.scaleX = image.scaleY = 1.25
		return image
	}
	
	private function update(e:AEvent):void {
		var image:ImageAA
		var i:int, l:int
		
		while (i < mLength) {
			image = mImgList[i++];
			image.rotation += 4
		}
	}
}

}